package com.neiquan.backstage.admin_user.impl;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.neiquan.backstage.admin_user.AdminUserService;
import com.neiquan.backstage.common.util.ExtraSpringHibernateTemplate;
import com.neiquan.backstage.pub.bsc.dao.po.AdminUser;

@Service
public class AdminUserServiceImpl implements AdminUserService {
	private static Class<?> poc = AdminUser.class;
	@Autowired
	private ExtraSpringHibernateTemplate extraSpringHibernateTemplate;

	@Override
	public AdminUser queryByAccount(String phone, Integer allianceMember) {
		DetachedCriteria detached = DetachedCriteria.forClass(poc);
		detached.add(Restrictions.eq("phone", phone));
		detached.add(Restrictions.eq("memberId", allianceMember));
		return extraSpringHibernateTemplate.findFirstOneByCriteria(detached);
	}

	@Override
	public AdminUser queryById(Integer id) {
		return extraSpringHibernateTemplate.findFirstOneByPropEq(poc, "userId", id);
	}
}
